﻿using System;
using NUnit.Framework;
using Smartkernel;

namespace Smartkernel.NUnitTest.
{
    [Category("Core")]
    [TestFixture]
    public class SmartDateTimeTest
    {
        [Test]
        public void Test()
        {
            //【01】计算两个日期的间隔（涉及方法：Distance）
            Assert.AreEqual(SmartDateTime.Distance(DateTime.Parse("1982-05-02 12:00"), DateTime.Parse("1982-05-02 15:00"), SmartDateTimeType.Hour), 3d);
            Assert.AreEqual(SmartDateTime.Distance(DateTime.Parse("1982-05-02 12:00"), DateTime.Parse("1982-05-02 12:00"), SmartDateTimeType.Millisecond), 0d);
            Assert.AreEqual(SmartDateTime.Distance(DateTime.Parse("1982-05-02 12:00"), DateTime.Parse("1982-05-02 12:30"), SmartDateTimeType.Minute), 30d);
            Assert.AreEqual(SmartDateTime.Distance(DateTime.Parse("1982-05-01 12:00"), DateTime.Parse("1982-05-01 12:00"), SmartDateTimeType.Month), 0d);
            Assert.AreEqual(SmartDateTime.Distance(DateTime.Parse("1982-05-02 12:00"), DateTime.Parse("1982-05-02 12:00"), SmartDateTimeType.Second), 0d);
            Assert.AreEqual(SmartDateTime.Distance(DateTime.Parse("1982-05-02 12:00"), DateTime.Parse("1982-05-02 12:00"), SmartDateTimeType.Year), 0d);

            //【02】求天数（涉及方法：GetDaysInMonth、GetDaysInYear）
            Assert.AreEqual(SmartDateTime.GetDaysInMonth(1982, 2), 28);
            Assert.AreEqual(SmartDateTime.GetDaysInYear(1982), 365);

            //【03】求属相（涉及方法：GetSmartTwelveAnimal）
            Assert.AreEqual(SmartDateTime.GetSmartTwelveAnimal(1982) == SmartTwelveAnimalType.狗, true);
        }
    }
}
